<html>
<head><meta charset="utf-8"><title>fields-ordered-by-offset · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/fields-ordered-by-offset.html">fields-ordered-by-offset</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="146797708"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/fields-ordered-by-offset/near/146797708" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/fields-ordered-by-offset.html#146797708">(Nov 05 2018 at 14:16)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> is there a cheap way to iterate an aggregate's fields sorted by offset? Seems the list on the layout is sorted by original field definition order. Currently I then sort a list of indices by their offsets, but that requires an allocation.</p>



<a name="146797719"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/fields-ordered-by-offset/near/146797719" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/fields-ordered-by-offset.html#146797719">(Nov 05 2018 at 14:16)</a>:</h4>
<p>yes it's how the LLVM backend works</p>



<a name="146797762"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/fields-ordered-by-offset/near/146797762" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/fields-ordered-by-offset.html#146797762">(Nov 05 2018 at 14:17)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/blob/master/src/librustc_codegen_llvm/type_of.rs#L124" target="_blank" title="https://github.com/rust-lang/rust/blob/master/src/librustc_codegen_llvm/type_of.rs#L124">https://github.com/rust-lang/rust/blob/master/src/librustc_codegen_llvm/type_of.rs#L124</a></p>



<a name="146797770"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/fields-ordered-by-offset/near/146797770" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/fields-ordered-by-offset.html#146797770">(Nov 05 2018 at 14:17)</a>:</h4>
<p>you could've also just, you know, looked at the API :D</p>



<a name="146861023"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/fields-ordered-by-offset/near/146861023" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/fields-ordered-by-offset.html#146861023">(Nov 06 2018 at 12:11)</a>:</h4>
<p>I did, but it seems I was blind. Sorry!</p>



<a name="146867308"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/fields-ordered-by-offset/near/146867308" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/fields-ordered-by-offset.html#146867308">(Nov 06 2018 at 14:22)</a>:</h4>
<p>heh, it's fine. I was mostly happy that it was at least somewhat discoverable, since there's a general issue of not being able to find "how do I do X" in rustc's codebase</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>